﻿<%@ Page Title="Approve timesheet" Language="C#" MasterPageFile="~/Timesheet.Master" AutoEventWireup="true"
    CodeBehind="ApproveTimesheet.aspx.cs" Inherits="Presentation.ApproveTimesheet" %>

<%@ Register Src="~/UserControl/ApproveTimesheet.ascx" TagName="TimesheetControl"
    TagPrefix="uc" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">
        $(document).ready(function () {
            $(".inp-form-small").hide();

            $(".styledselect_form_2").change(function () {
                if ($(this).val() == "2") {
                    $(this).parent().next().children().show("1000");
                } else {
                    $(this).parent().next().children().hide("1000");
                }
            });

            $(".form-save").click(function () {
                if ($(".styledselect_form_2").length == 0) {
                    alert("No pending timesheet");
                    return false;
                }
                var timesheets = document.getElementById('<%=ListTimesheetId.ClientID%>');
                var statuses = document.getElementById('<%=ListStatus.ClientID%>');
                var reasons = document.getElementById('<%=ListReason.ClientID%>');

                timesheets.setAttribute("value", "");
                statuses.setAttribute("value", "");
                reasons.setAttribute("value", "");

                $(".styledselect_form_2").each(function (index) {
                    old = statuses.getAttribute("value");
                    if (old == null) {
                        old = "";
                    }
                    statuses.setAttribute("value", old + $(this).find("option:selected").val() + "\n");

                    timesheetsIdOld = timesheets.getAttribute("value");
                    if (timesheetsIdOld == null) {
                        timesheetsIdOld = "";
                    }
                    timesheets.setAttribute("value", timesheetsIdOld + $(this).attr("name") + "\n");
                });
                $(".inp-form-small").each(function (index) {
                    old = reasons.getAttribute("value");
                    if (old == null) {
                        old = "";
                    }
                    reasons.setAttribute("value", old + $(this).val() + "\n");
                });
            });
        });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:HiddenField ID="ListTimesheetId" Value="" runat="server" />
    <asp:HiddenField ID="ListStatus" Value="" runat="server" />
    <asp:HiddenField ID="ListReason" Value="" runat="server" />
    <div id="page-heading">
        <h1>
            Approve Timesheet</h1>
    </div>
    <uc:TimesheetControl ID="TimesheetControl" runat="server" />
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Footer" runat="server">
</asp:Content>
